﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>微街秀 > 提现到支付宝</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no" />
    <link href="plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="css/css.css" />
    <link href="css/Makezfbset.css" rel="stylesheet" type="text/css" />
    <script src="js/jquery-2.1.4.min.js" type="text/javascript"></script>
    <script src="plugins/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
    <script src="js/ajax-data.js" type="text/javascript"></script>
    <script src="js/base.js" type="text/javascript"></script>
    <script src="js/dialog.js" type="text/javascript"></script>
    <script src="js/gl-dialog.js" type="text/javascript"></script>
    <style>
        #headimg
        {
            height: 70px;
            border-radius: 100px;
        }
    </style>
</head>
<body>
    <div>
        <input type="hidden" id="refID" value="0" />
        <div class="wamtop">
            <div class="topleft back" onclick="GoBack()">
                <img src="img/5.jpg" />
            </div>

            <div class="topcententxt">           
            </div>

             <div class="topright" id="zfb_set" style="color:white;top:10px;right:15px; display:none;">
                设置
            </div>
        </div>
        <div id="name_1" style="position: relative; top: 20px; padding: 30px 0 30px 0; display: none;">
            <div style="text-align: center">
                <a href="javascript:" onclick="WXOauth()">
                    <img id="headimg" src="img/39_50.png" /></a><br />
                <div id="nickname" style="padding-top: 10px; font-size: 18px;">
                </div>
                <div style="padding-top: 10px; color: #F37B0B">
                    <a href="javascript:" onclick="WXOauth()">选择微信收款账号</a></div>
            </div>
        </div>
        <div id="name_2" style="position: relative; top: 20px; padding-left: 20px; display: none;">
            支付宝账号：<span class="ali_name"></span>
        </div>
        <div id="alipay_name" style="position: relative; top: 28px; padding-left: 20px; display: none;">
            姓名：<span class="alipay_name"></span>
        </div>
        <div class="nickname" style="margin-top: 10%">
            <input type="number" class="nicknametext" id="amount" placeholder="请输入金额（元）" />
        </div>
        <div style="width: 93%; margin-left: auto; margin-right: auto; padding-top: 5px;
            color: #999;">
            余额：<span id="balance" style="font-weight: bold;">0.00</span> 元</div>
            
        <div class="nicksave" style="margin-top: 30%">
            <div class="submits" style="font-size: 16px; color: White;">
                确定</div>
        </div>
    </div>


    
        <div class="backimg-panl buzhou hide">
            <div class="font-content" style="top: 15%;">
                <img src="img/buzhou/4_3.png" class=" center-block" style=" width:40%;" />
                <div class=" text-center" style="margin-bottom: -70px;">
                    <p>
                        点击此处</p>
                    <p>
                        可切换微信账号</p>
       
                    <p>
                        <button class=" btn btn-color btn-default " onclick="NextBZ(1)">
                            下一步</button></p>
                </div>
            </div>
        </div>
        <div class="backimg-panl buzhou hide">
            <div class="font-content" style="top: 40%;">
                <img src="img/buzhou/4_4.png" />
                <div class=" text-center" style="margin-bottom: -70px;">
                    <p>
                        输入提现金额</p>
                    <p>
                        <button class=" btn btn-color btn-default " onclick="UpBZ(1)">
                            上一步</button></p>
                    <p>
                        <button class=" btn btn-color btn-default " onclick="NextBZ(2)">
                            下一步</button></p>
                </div>
            </div>
        </div>
        <div class="backimg-panl buzhou hide">
            <div class="font-content" style="top: 50%;">
                <img src="img/buzhou/4_5.png" />
                <div class=" text-center" style=" margin-top: -40px;">
                    <p>
                        点击确定</p>
                    <p>
                        一个工作日内即可到账</p>
                    <p>
                        <button class=" btn btn-color btn-default " onclick="SetBZ(42)">
                            知道了</button></p>
                    <p>
                </div>
            </div>
        </div>
    
    <script>
        var openid = "", platform, balance, type;
        $(document).ready(function () {
            loadParam();
            if (IsMobile() < 1) {
                Alert('下载APP才能使用');
                return;
            }
            load(1);
            $(".submits").bind("click", submits);
            $("#zfb_set").bind("click", Set);
            if (platform == 1)
                ShowBZ(42);
        });

        function load(page) {
            if (!islogin()) { window.location.href = 'login.html'; return; }
            keyword = $("#Stext").val();
            AjaxStart("ajax/fc_setting.ashx?get", "", function (data) {
                loadhtml(data);
            });
        }

        function loadhtml(data) {
            $(".ali_name").html(data.item.ali_name);
            $(".alipay_name").text(data.item.ali_truename);
        }

        function loadParam() {
            type = getQueryString("type");          //1 广告主, 2 分享者
            platform = getQueryString("platform");  //1 支付宝，2 微信
            if (getQueryString("balance") != null) {
                balance = getQueryString("balance");
            }
            $("#balance").html(balance);
            if (platform == "1") {
                $(".topcententxt").html("申请微信提现");
                $("#name_1").css("display", "");

                openid = getQueryString("openid");
                if (getQueryString("iswx") == 1) {
                    $("#nickname").html(getQueryString("nickname"));
                    $("#headimg").attr("src", getQueryString("headimg"));
                    if (openid == null || openid == "" || openid.indexOf("defined") > -1) {
                        Alert("微信授权失败");
                        setTimeout(function () { window.location.href = 'Makesh_3.html' }, 1000);
                    }
                }
            }
            else if (platform == "2") {
                $(".topcententxt").html("申请支付宝提现");
                $("#name_2").show();
                $("#alipay_name").show();
                $("#zfb_set").css("display", "");
            }
        }

        //微信授权
        function WXOauth() {
            var param = { callback: "Call_WXOauth", platform: "weixin" };
            var p = JSON.stringify(param);
            window.location.href = "callback://doOauth?" + p;
        }

        function Call_WXOauth(jsonStr) {
            var json = JSON.parse(jsonStr);
            var openid = json.openid;
            var headimgurl = encodeURIComponent(json.headimgurl);
            var nickname = encodeURIComponent(json.nickname);
            document.location.href = "makezfbdrop.html?platform=1&type=" + type + "&iswx=1&openid=" + openid + "&nickname=" + nickname + "&headimg=" + headimgurl + "&balance=" + balance;
        }

        function submits() {
            var amount = $("#amount").val();
            if (trim(amount) == "") {
                Alert("请输入金额");
                return;
            }
            if (isNaN(amount) || parseFloat(amount) < 1) {
                Alert("请输入大于1的数字");
                return;
            }
            if (!isNaN(balance)) {
                if (parseFloat(amount) > parseFloat(balance)) {
                    Alert("最多允许提现" + balance + "元");
                    return;
                }
            }
            if (getQueryString("platform") == "1") {
                if (openid == null || openid == "" || openid.indexOf("defined") > -1) {
                    Alert("请选择微信收款账号");
                    return;
                }
            }

            if (platform == "2") {
                if (!confirm("请确认提现信息：\n提现平台:支付宝\n账号:" + $(".ali_name").text() + "\n提现金额:" + amount + "元"))
                    return false;
            }
            else if (platform == "1") {
                if (!confirm("请确认提现信息：\n提现平台:微信钱包\n微信昵称:" + $("#nickname").html() + "\n提现金额:" + amount + "元"))
                    return false;
            }
            else {
                return;
            }
            AjaxStart("ajax/fc_cash.ashx?add", "&platform=" + platform + "&amount=" + amount + "&openid=" + openid + "&nickname=" + $("#nickname").html() + "&type=" + type, function (data) {
                if (data.code == 0) {
                    $("#amount").val("");
                    var s = trim($("#balance").html());
                    if (!isNaN(s)) {
                        balance = parseFloat(s) - parseFloat(amount);
                        if (balance < 0) balance = 0;
                        $("#balance").html(balance.toFixed(2));
                    }
                    Alert("申请成功，1个工作日内钱会转入您的账户");
                }
                else if (data.code == 1012) {
                    //没有验证手机号
                    GlAlert({ body: "请先验证手机号,立即验证?", ok: { callback: function () { window.location.href = "validate-phone.html"; }
                    },
                        cancel: {}
                    });
                }
                else
                    Alert(data.msg);
            });
        }
        function GoBack() {
            if (type == 1)
                window.location.href = 'Makead_1.html';
            else
                window.location.href = 'Makesh_3.html'
        }
        function Set() {
            window.location.href = 'makezfbset.html?url='+ encodeURIComponent('makezfbdrop.html?platform=2&type=1&balance=' + $("#balance").html());
        }
    </script>
</body>
</html>
